package com.jingyanzi.marketing.service.impl;
import java.util.ArrayList;
import java.util.List;

import com.jingyanzi.marketing.domain.AccountDiscountDo;
import com.jingyanzi.marketing.domain.ActivityDo;
import com.jingyanzi.marketing.domain.DiscountDo;
import com.jingyanzi.marketing.domain.DiscountLogDo;
import com.jingyanzi.marketing.domain.GiveDo;
import com.jingyanzi.marketing.domain.GoodsDo;
import com.jingyanzi.marketing.domain.PresentDo;
import com.jingyanzi.marketing.domain.PresentExchangeDo;
import com.jingyanzi.marketing.domain.VoucherDo;
import com.jingyanzi.marketing.entity.MaAccountDiscount;
import com.jingyanzi.marketing.entity.MaActivity;
import com.jingyanzi.marketing.entity.MaDiscount;
import com.jingyanzi.marketing.entity.MaDiscountLog;
import com.jingyanzi.marketing.entity.MaGive;
import com.jingyanzi.marketing.entity.MaGoods;
import com.jingyanzi.marketing.entity.MaPresent;
import com.jingyanzi.marketing.entity.MaPresentExchange;
import com.jingyanzi.marketing.entity.MaVoucher;
import com.jingyanzi.marketing.util.BeanUtilsExtends;

/**
 * @author reagan
 * @Description:基础服务类主要用来实现底层的通用方法
 */
public class BaseServiceImpl {

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param maAccountDiscount
	 * @return 返回DO对象
	 */
	public AccountDiscountDo getMaAccountDiscountDo(MaAccountDiscount maAccountDiscount) {
		if (maAccountDiscount == null)
			return null;
		AccountDiscountDo dst = new AccountDiscountDo();
		return BeanUtilsExtends.copyProperties(dst, maAccountDiscount) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<AccountDiscountDo> getMaAccountDiscountDoList(List<MaAccountDiscount> list) {
		List<AccountDiscountDo> result = new ArrayList<AccountDiscountDo>();
		if (list != null && !list.isEmpty()) {
			for (MaAccountDiscount org : list) {
				AccountDiscountDo org1 = getMaAccountDiscountDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public ActivityDo getMaActivityDo(MaActivity obj) {
		if (obj == null)
			return null;
		ActivityDo dst = new ActivityDo();
		dst = BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
		if (obj.getRegion() != null) {
			dst.setRegion(obj.getRegion().split("\\,"));
			dst.setRegionCode(obj.getRegionCode().split("\\,"));
		}
		if (obj.getActivityDate() != null) {
			dst.setActivityDate(String.valueOf(obj.getActivityDate().getTime()));
		}
		if (obj.getActivityEndDate() != null) {
			dst.setActivityEndDate(String.valueOf(obj.getActivityEndDate().getTime()));
		}
		return dst;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<ActivityDo> getMaActivityDoList(List<MaActivity> list) {
		List<ActivityDo> result = new ArrayList<ActivityDo>();
		if (list != null && !list.isEmpty()) {
			for (MaActivity org : list) {
				ActivityDo org1 = getMaActivityDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public DiscountDo getMaDiscountDo(MaDiscount obj) {
		if (obj == null)
			return null;
		DiscountDo dst = new DiscountDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<DiscountDo> getMaDiscountDoList(List<MaDiscount> list) {
		List<DiscountDo> result = new ArrayList<DiscountDo>();
		if (list != null && !list.isEmpty()) {
			for (MaDiscount org : list) {
				DiscountDo org1 = getMaDiscountDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public DiscountLogDo getMaDiscountLogDo(MaDiscountLog obj) {
		if (obj == null)
			return null;
		DiscountLogDo dst = new DiscountLogDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<DiscountLogDo> getMaDiscountLogDoList(List<MaDiscountLog> list) {
		List<DiscountLogDo> result = new ArrayList<DiscountLogDo>();
		if (list != null && !list.isEmpty()) {
			for (MaDiscountLog org : list) {
				DiscountLogDo org1 = getMaDiscountLogDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public GiveDo getMaGiveDo(MaGive obj) {
		if (obj == null)
			return null;
		GiveDo dst = new GiveDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	public List<GiveDo> getMaGiveDoList(List<MaGive> list) {
		List<GiveDo> result = new ArrayList<GiveDo>();
		if (list != null && !list.isEmpty()) {
			for (MaGive org : list) {
				GiveDo org1 = getMaGiveDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public GoodsDo getMaGoodsDo(MaGoods obj) {
		if (obj == null)
			return null;
		GoodsDo dst = new GoodsDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	public List<GoodsDo> getMaGoodsDoList(List<MaGoods> list) {
		List<GoodsDo> result = new ArrayList<GoodsDo>();
		if (list != null && !list.isEmpty()) {
			for (MaGoods org : list) {
				GoodsDo org1 = getMaGoodsDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public PresentExchangeDo getMaPresentExchangeDo(MaPresentExchange obj) {
		if (obj == null)
			return null;
		PresentExchangeDo dst = new PresentExchangeDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	public List<PresentExchangeDo> getMaPresentExchangeDoList(List<MaPresentExchange> list) {
		List<PresentExchangeDo> result = new ArrayList<PresentExchangeDo>();
		if (list != null && !list.isEmpty()) {
			for (MaPresentExchange org : list) {
				PresentExchangeDo org1 = getMaPresentExchangeDo(org);
				if (org1 != null) {
					if(null != org.getCreatetime()) {
						org1.setExchangeTimeStamp(org.getCreatetime().getTime() + "");
					}
					result.add(org1);
				}
			}
		}
		return result;
	}

	public PresentDo getMaPresentDo(MaPresent obj) {
		if (obj == null)
			return null;
		PresentDo dst = new PresentDo();
		dst = BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
		if (obj.getExchange() == null) {
			dst.setExchange(obj.getExchange());
		}
		if (obj.getRegion() != null) {
			dst.setRegion(obj.getRegion().split("\\,"));
			dst.setRegionCode(obj.getRegionCode().split("\\,"));
		}
		return dst;
	}

	public List<PresentDo> getMaPresentDo(List<MaPresent> list) {
		List<PresentDo> result = new ArrayList<PresentDo>();
		if (list != null && !list.isEmpty()) {
			for (MaPresent org : list) {
				PresentDo org1 = getMaPresentDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	public VoucherDo getMaVoucherDo(MaVoucher obj) {
		if (obj == null)
			return null;
		VoucherDo dst = new VoucherDo();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	public List<VoucherDo> getMaVoucherList(List<MaVoucher> list) {
		List<VoucherDo> result = new ArrayList<VoucherDo>();
		if (list != null && !list.isEmpty()) {
			for (MaVoucher org : list) {
				VoucherDo org1 = getMaVoucherDo(org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	

}
